<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="utf-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<html>
<head>
    <title>黑名单用户配置界面</title>
    <link type="text/css" rel="stylesheet" href='<spring:url value="/webjars/bootstrap/3.3.5/css/bootstrap.min.css"/>' />
    <link type="text/css" rel="stylesheet" href='<spring:url value="/webjars/bootstrap/3.3.5/css/bootstrap-theme.min.css"/>' />
    <link type="text/css" rel="stylesheet" href='<spring:url value="/resources/css/content.css"/>'/>
    <script src='<spring:url value="/webjars/jquery/1.11.1/jquery.min.js"/>'></script>
    <script src='<spring:url value="/webjars/bootstrap/3.3.5/js/bootstrap.js"/>'></script>
    <script src='<spring:url value="/webjars/angularjs/1.5.5/angular.min.js"/>'></script>
    <script src='<spring:url value="/webjars/angularjs/1.5.5/angular-resource.js"/>'></script>
    <script src='<spring:url value="/webjars/bootbox/4.4.0/bootbox.js"/>' ></script>
    <script src='<spring:url value="/resources/js/common/PageUtil.js"/>'></script>
    <script src='<spring:url value="/resources/js/common/Constant.js"/>'></script>
    <script src='<spring:url value="/resources/js/common/MessageBox.js"/>'></script>
    <script src='<spring:url value="/resources/js/blackList/BlackListModel.js"/>'></script>
    <script src='<spring:url value="/resources/js/blackList/BlackListService.js"/>'></script>
    <script src='<spring:url value="/resources/js/blackList/BlackListController.js"/>'></script>
</head>
<body ng-app="blackListApp" ng-controller="blackListCtrl">
    <div class="adcc-container">
        <ol class="breadcrumb">
            <li class="active">用户管理</li>
            <li class="active">黑名单用户配置</li>
        </ol>
        <form class="form-inline">
            <select class="form-control" ng-model="searchGWUserId" ng-init="searchGWUserId='0'">
                <option value="0" >--</option>
                <option ng-repeat="x in userConfigsList" value="{{x.id}}">{{x.userName}}</option>
            </select>
            <button type="submit" ng-click="findByConditions(search)" class="btn btn-primary">查询</button>
                    <button type="button" class="btn btn-success formQueryBtn-style" ng-click="createBlackList()">新增</button>
                    <button type="button" class="btn btn-info formQueryBtn-style" ng-click="push()">推送</button>
                    <button type="button" class="btn btn-success formQueryBtn-style" ng-click="download()">下载</button>
        </form>
        <div class="adcc-content">
            <table class="table table-bordered table-striped table-condensed table-hover">
            <thead>
            <tr>
                <th>用户</th>
                <th>发送地址</th>
                <th>接收地址</th>
                <th>SMI</th>
                <th>机尾号</th>
                <th>关键字</th>
                <th>起始位</th>
                <th>编辑</th>
                <th>删除</th>
            </tr>
            </thead>
            <tbody>
            <tr ng-repeat="blackList in blackLists">
                <td>{{ blackList.name }}</td>
                <td>{{ blackList.sendAddress }}</td>
                <td>{{ blackList.recvAddress }}</td>
                <td>{{ blackList.smi }}</td>
                <td>{{ blackList.an }}</td>
                <td>{{ blackList.specLable }}</td>
                <td>{{ blackList.index }}</td>
                <td class="tabBtn-style">
                    <button class="btn btn-info btn-xs" ng-click="updateBlackList(blackList)">
                        <span class="glyphicon glyphicon-pencil"></span>&nbsp;&nbsp;修改
                    </button>
                </td>
                <td class="tabBtn-style">
                    <button class="btn  btn-danger btn-xs" ng-click="deleteBlackList(blackList.id)">
                        <span class="glyphicon glyphicon-remove"></span>&nbsp;&nbsp;删除
                    </button>
                </td>
            </tr>
            </tbody>
        </table>
    </div>
        <nav class="form-inline nav-style">
            <ul class="pagination">
                <li id="top" class="input-group">
                    <a ng-click="firstPage()">
                        <span>首页</span>
                    </a>
                </li>
                <li id="previous" class="input-group">
                    <a ng-click="previous()">
                        <span>上一页</span>
                    </a>
                </li>
                <li ng-repeat="page in pageList" ng-class="{active: isActivePage(page)}" class="input-group">
                    <a ng-click="selectCurrentPage(page)" class="form-control">{{ page }}</a>
                </li>
                <li id="next" class="input-group">
                    <a ng-click="next()">
                        <span>下一页</span>
                    </a>
                </li>
                <li id="bottom" class="input-group">
                    <a ng-click="lastPage()">
                        <span>尾页</span>
                    </a>
                </li>
                <li class="input-group">
                    <%--可设置默认条数--%>
                        <select ng-model="selectPageSize" class="form-control"
                                ng-init="selectPageSize='15'"
                                ng-change="changePageSize(selectPageSize)">
                            <option value="15">15</option>
                            <option value="50">50</option>
                            <option value="100">100</option>
                        </select>
                </li>
            </ul>
        </nav>

    </div>

    <%--新增和修改模态框--%>
    <div class="modal fade" id="dialogBlackList" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" style="margin-top: 100px;pxoverflow-y: auto" data-backdrop="static">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h4 class="modal-title" ><span id="glyphicon" class="glyphicon glyphicon-plus" aria-hidden="true"></span>{{title}}</h4>
                </div>
                <div class="modal-body">
                    <form name="formBlackList" id="f1" method="post" onkeydown="if(event.keyCode==13){return false;}">
                        <div class="form-group">
                            <label for="gwUserId">名称</label>
                            <select name="gwUserId" id="gwUserId" class="form-control" ng-model="blackList.gwUserId" required ng-init="blackList.gwUserId='0'"
                                    ng-blur="checkIUName(blackList.gwUserId)">
                                <option value="0">-- 请选择 --</option>
                                <option ng-repeat="x in userConfigsList" value="{{x.id}}">{{x.userName}}</option>
                            </select>
                            <div class="error" ng-show="formBlackList.gwUserId.$dirty && formBlackList.gwUserId.$invalid">
                                <small class="error" ng-show="formBlackList.gwUserId.$error.unique"><span class="font-style">黑名单用户名已存在</span></small>
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="sendAddress">发送地址</label>
                            <input type="text" class="form-control" id="sendAddress" name="sendAddress" ng-model="blackList.sendAddress" ng-blur="change(true)" ng-focus="change(false)" ng-maxlength="7" ng-pattern="/^[0-9|A-Z|\*]{7}$/">
                            <div class="error" ng-show="formBlackList.sendAddress.$dirty && formBlackList.sendAddress.$invalid">
                                <small class="error" ng-show="formBlackList.sendAddress.$error.maxlength && changed"><span class="font-style">最大长度7</span></small>
                                <small class="error" ng-show="formBlackList.sendAddress.$error.pattern && changed"><span class="font-style">请输入大写字母、数字或*,长度7位</span></small>
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="recvAddress">接收地址</label>
                            <input type="text" class="form-control" id="recvAddress" name="recvAddress" ng-model="blackList.recvAddress" ng-blur="change(true)" ng-focus="change(false)" ng-maxlength="300" ng-pattern="/^[0-9A-Z*]{7}(?:,[0-9A-Z*]{7})*$/" placeholder="多个请以英文逗号间隔">
                            <div class="error" ng-show="formBlackList.recvAddress.$dirty && formBlackList.recvAddress.$invalid">
                                <small class="error" ng-show="formBlackList.recvAddress.$error.maxlength && changed"><span class="font-style">最大长度300</span></small>
                                <small class="error" ng-show="formBlackList.recvAddress.$error.pattern && changed"><span class="font-style">请输入大写字母、数字或者* 7位一组 多个以英文逗号间隔</span></small>
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="smi">SMI</label>
                            <input type="text" class="form-control" id="smi" name="smi" ng-model="blackList.smi" ng-blur="change(true)" ng-focus="change(false)" ng-maxlength="100" ng-pattern="/^[0-9A-Z*]{3}(?:,[0-9A-Z*]{3})*$/" placeholder="多个请以英文逗号间隔">
                            <div class="error" ng-show="formBlackList.smi.$dirty && formBlackList.smi.$invalid">
                                <small class="error" ng-show="formBlackList.smi.$error.maxlength && changed"><span class="font-style">最大长度100</span></small>
                                <small class="error" ng-show="formBlackList.smi.$error.pattern && changed"><span class="font-style">请输入大写字母、数字或者* 3位一组 多个以英文逗号间隔</span></small>
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="an">机尾号</label>
                            <input type="text" class="form-control" id="an" name="an" ng-blur="change(true)" ng-focus="change(false)" ng-maxlength="100" ng-pattern="/^[0-9A-Z\-*]+(?:,[0-9A-Z\-*]+)*$/" ng-model="blackList.an">
                            <div class="error" ng-show="formBlackList.an.$dirty && formBlackList.an.$invalid">
                                <small class="error" ng-show="formBlackList.an.$error.maxlength && changed"><span class="font-style">最大长度100</span></small>
                                <small class="error" ng-show="formBlackList.an.$error.pattern && changed"><span class="font-style">请输入大写字母、数字或者- * 多个以英文逗号间隔</span></small>
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="specLable">全文关键字</label>
                            <input type="text" class="form-control" id="specLable" name="specLable" ng-blur="change(true)" ng-focus="change(false)" ng-maxlength="300" ng-pattern="/^[\u000a|\u000d|\u0020-\u007e]*$/" ng-model="blackList.specLable">
                            <div class="error" ng-show="formBlackList.specLable.$dirty && formBlackList.specLable.$invalid">
                                <small class="error" ng-show="formBlackList.specLable.$error.maxlength && changed"><span class="font-style">最大长度300</span></small>
                                <small class="error" ng-show="formBlackList.specLable.$error.pattern && changed"><span class="font-style">请输入符合620规范的字符</span></small>
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="index">关键字起始位</label>
                            <input type="text" class="form-control" id="index" name="index" ng-blur="change(true)" ng-focus="change(false)"
                                    ng-pattern="/^[0-9]*$/"ng-model="blackList.index"
                                    ng-min="0"   ng-init="blackList.index='0'" ng-maxlength="10" required>
                            <div class="error" ng-show="formBlackList.index.$dirty && formBlackList.index.$invalid">
                                <small class="error" ng-show="formBlackList.index.$error.maxlength && changed"><span class="font-style">最大长度10</span></small>
                                <small class="error" ng-show="formBlackList.index.$error.pattern && changed"><span class="font-style">请输入数字</span></small>
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-md-3 col-md-offset-9">
                                <button type="submit" ng-disabled="formBlackList.$invalid" ng-click="save(blackList,formBlackList.$valid)" class="btn btn-primary">保存</button>
                                <button type="button" ng-click="close()" class="btn btn-danger">取消</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
